home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / CRYPT17.ZIP / VECTOR.ASM < prev    next >
Assembly Source File  |  1993-08-13  |  5KB  |  170 lines

  1. ;VECTOR - Interrupt Vector address listing utility
  2. ;by KohnTarK for Crypt Newsletter 17.
  3.  
  4. ;After staring endlessly at the vector interrupt table using 
  5. ;memory editors and dump programs, I realized that as blindness approached 
  6. ;humans aren't meant to do such things such as counting 
  7. ;on fingers and pointing at the screen with pencils. So I wrote a quick 
  8. ;& dirty utility that will output the segments and offsets of all 
  9. ;interrupt vectors in hexadecimal notation.
  10.  
  11. ;This is especially useful when writing resident code or dealing with
  12. ;resident Anti-Virus software, and trying to figure out what vectors 
  13. ;are hooked the specific addresses for tracing purposes.
  14.  
  15.  
  16. ;USAGE:
  17.  
  18. ;vector |more 
  19.  
  20. ;(DOS's MORE directory has to be in the PATH) will output the
  21. ;interrupt vectors one screenful at the time.
  22.  
  23.  
  24. ;vector > <filename>  (No, you don't type the <>'s)
  25.  
  26. ;will output the interrupt vectors to <filename>
  27. ;<filename> is useful to keep as a reference of different DOS versions, 
  28. ;memory configurations, resident AV programs etc. etc.
  29.  
  30. ;$
  31.  
  32. ;****************************************************************************
  33. ;
  34. ; VECTOR.ASM
  35. ; AUTHOR: K$hntark
  36. ; DATE:   10 APRIL 93
  37. ; Assemble & link with Turbo Assembler.
  38. ;****************************************************************************
  39.  
  40. MAIN    SEGMENT BYTE
  41.         ASSUME cs:main,ds:main,ss:nothing      ;all part in one segment=com file
  42.         org    100h
  43.  
  44. VECTORS:
  45.             
  46.  
  47.          mov  ah,09     ;print message
  48.          lea  dx,[START]
  49.          int  21h
  50.  
  51.           xor  di,di                     ;interrupt count
  52.           xor  bx,bx
  53.           push bx
  54.           pop  es                        ;es = 0000
  55.           mov  cx,0FFh                   ;#of vectors = 256 = FF
  56.           mov  si,0000                   ;starting offset
  57.           
  58. LOOP1:
  59.           mov  bx,es:WORD PTR[si]   ;put vector's offset of in xx
  60.           call PRINT_MSG1
  61.           call BIN_TO_HEX
  62.  
  63.           
  64.           mov  bx,es:WORD PTR[si+2]  ; put vector's segment in bx
  65.           call  PRINT_MSG2
  66.           call  BIN_TO_HEX        
  67.  
  68.           add si,4
  69.  
  70.           loop LOOP1
  71.  
  72.           int 20h
  73.  
  74. ;****************************************************************************
  75. PRINT_MSG1:
  76.             push ax
  77.             
  78.             mov  ah,09     ;print carriage return
  79.             lea  dx,[CR]
  80.             int  21h
  81.             
  82.  
  83.                            ;print carriage return
  84.             int  21h
  85.             
  86.             
  87.                            ;print INTERRUPT # message
  88.             lea  dx,[INT_NUM]
  89.             int  21h
  90.             
  91.             push bx         ;print int #
  92.             mov  bx,di
  93.             call BIN_TO_HEX
  94.             inc  di
  95.             pop  bx
  96.             
  97.             mov  ah,09     ;print carriage return
  98.             lea  dx,[CR]
  99.             int  21h
  100.             
  101.             mov  ah,09       ;print OFFSET
  102.  
  103.             lea  dx,[MSG1]
  104.             int  21h
  105.  
  106.             pop  ax
  107.             ret
  108.  
  109. ;****************************************************************************
  110. PRINT_MSG2:
  111.             push ax
  112.             
  113.             mov  ah,09     ;print carriage return
  114.             lea  dx,[CR]
  115.             int  21h
  116.             
  117.             ;mov  ah,09     ;print message
  118.             lea  dx,[MSG2]
  119.             int  21h
  120.             
  121.  
  122.  
  123.             pop  ax
  124.             ret
  125.  
  126. ;****************************************************************************
  127. ; display # on bx
  128.  
  129. BIN_TO_HEX:
  130.             push cx
  131.             push dx
  132.             
  133.             mov  ch,04    ;# of digits to process
  134. ROTATE:     mov  cl,04    ;# of bits to rotate
  135.             rol  bx,cl    ;rotate bx l to r  
  136.             mov  al,bl    ;move to al  (2 digits)
  137.             and  al,0Fh   ;mask off upper digit
  138.             add  al,30h   ;convert to ASCII
  139.             cmp  al,3Ah   ;is it > 9?
  140.             jl   PRINTIT  ;jump of digit =0 to 9
  141.             add  al,07h   ;digit is A to F
  142.  
  143. PRINTIT:
  144.             mov dl,al
  145.             mov ah,2
  146.             int 21h
  147.             dec ch
  148.             jnz ROTATE
  149.  
  150.             pop  dx
  151.             pop  cx
  152.             ret
  153. ;****************************************************************************
  154.  
  155. START    db 'MMMMMMMMMMMMMMMMMMMMMMMMMMM',13d,10d
  156.          db ' VECTORS.COM               ',13d,10d
  157.          db ' Interrupt Vectors Listing ',13d,10d
  158.          db ' (C) 1993 by K$hntark      ',13d,10d 
  159.          db 'MMMMMMMMMMMMMMMMMMMMMMMMMMM','$'
  160. INT_NUM  db 'INTERRUPT # ','$'
  161. MSG1     db  'OFFSET:  ','$'
  162.  
  163. CR       db  13d,10d,'$'
  164. MSG2     db  'SEGMENT: ','$'
  165.  
  166.  
  167. MAIN ENDS
  168.      END VECTORS
  169.  
  170.